{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import tensorflow as tf\n",
    "import tensorflow.keras as keras\n",
    "import tensorflow.keras.layers as layers\n",
    "import numpy as np\n",
    "import pandas as pd\n",
    "from tqdm import tqdm"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "         0     1     2       3       4       5\n",
      "0     1.93  0.32  0.76  409.25  265.14  -80.20\n",
      "1     1.97 -0.02  1.00  485.79  236.46  -76.05\n",
      "2     1.97 -0.44  1.25  557.08  194.83  -72.21\n",
      "3     1.97 -0.98  1.56  595.36  148.32  -81.30\n",
      "4     1.97 -1.54  1.93  575.88  116.28 -101.81\n",
      "...    ...   ...   ...     ...     ...     ...\n",
      "2995  0.48 -1.82 -0.36 -295.60 -490.43  -97.11\n",
      "2996  0.36 -1.70 -0.61 -256.42 -489.09  -55.48\n",
      "2997  0.28 -1.56 -0.80 -228.46 -460.34  -20.51\n",
      "2998  0.19 -1.46 -0.96 -207.10 -418.59    4.52\n",
      "2999  0.08 -1.40 -1.16 -187.32 -365.67   24.72\n",
      "\n",
      "[3000 rows x 6 columns]\n",
      "         0     1     2       3       4       5\n",
      "0    -1.60  0.16  1.47  210.88 -187.38 -425.61\n",
      "1     1.98  0.72  1.61  208.69 -124.03 -365.92\n",
      "2     1.97  1.04  1.60  205.27  -62.14 -274.79\n",
      "3     1.97  1.07  1.54  185.43   -1.04 -177.31\n",
      "4    -1.92  0.82  1.42  153.14   49.68  -89.72\n",
      "...    ...   ...   ...     ...     ...     ...\n",
      "2995  0.76  0.19  1.02  -26.43  -44.92    3.72\n",
      "2996  0.77  0.24  1.14  -37.42  -51.15  -18.19\n",
      "2997  0.91  0.30  1.15  -40.10  -47.43   -4.15\n",
      "2998  0.89  0.30  1.12  -29.42  -65.19   17.82\n",
      "2999  0.83  0.26  1.09   -9.22  -78.86   35.46\n",
      "\n",
      "[3000 rows x 6 columns]\n"
     ]
    }
   ],
   "source": [
    "skip = pd.read_csv('data/skip.csv', header = None)\n",
    "normal = pd.read_csv('data/normal.csv', header = None)\n",
    "print(skip)\n",
    "print(normal)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "SAMPLES_PER_GESTURE = 30"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [],
   "source": [
    "def processData(d, v):\n",
    "    dataX = np.empty([0,SAMPLES_PER_GESTURE*6])\n",
    "    dataY = np.empty([0])\n",
    "\n",
    "    data  = d.values\n",
    "    dataNum = data.shape[0] // SAMPLES_PER_GESTURE\n",
    "\n",
    "\n",
    "    for i in tqdm(range(dataNum)):\n",
    "        tmp = []\n",
    "        for j in range(SAMPLES_PER_GESTURE):  # 正规化\n",
    "            tmp += [(data[i * SAMPLES_PER_GESTURE + j][0] + 2.0) / 4.0]\n",
    "            tmp += [(data[i * SAMPLES_PER_GESTURE + j][1] + 2.0) / 4.0]\n",
    "            tmp += [(data[i * SAMPLES_PER_GESTURE + j][2] + 2.0) / 4.0]\n",
    "            tmp += [(data[i * SAMPLES_PER_GESTURE + j][3] + 2000.0) / 4000.0]\n",
    "            tmp += [(data[i * SAMPLES_PER_GESTURE + j][4] + 2000.0) / 4000.0]\n",
    "            tmp += [(data[i * SAMPLES_PER_GESTURE + j][5] + 2000.0) / 4000.0]\n",
    "\n",
    "        tmp = np.array(tmp)\n",
    "\n",
    "        tmp = np.expand_dims(tmp, axis = 0)\n",
    "\n",
    "        dataX = np.concatenate((dataX, tmp), axis = 0)\n",
    "        dataY = np.append(dataY, v)\n",
    "\n",
    "    return dataX, dataY"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 100/100 [00:00<00:00, 3934.21it/s]\n",
      "100%|██████████| 100/100 [00:00<00:00, 4350.08it/s]\n"
     ]
    }
   ],
   "source": [
    "skipX, skipY = processData(skip, 0)\n",
    "normalX, normalY = processData(normal, 1)\n",
    "dataX = np.concatenate((skipX, normalX), axis = 0)\n",
    "dataY = np.concatenate((skipY, normalY), axis = 0)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[196 181  12 193  34  43  98 197 139 171  66  51  60 109 176 156 143  49\n",
      " 137 177  84  90  55 175 195  59   2 110 190 151 122 169  70  31 150  94\n",
      " 198 184 154  39  45  23  67 121  92  15 144 178  35 105 188  54  48 141\n",
      " 155   8  16 159  22  63  26 107  10 185  30  56  27  91 138 118  76  57\n",
      "  81 163 136  20  74 180   5 112 119  82  17 189   1 113 153 101  89 199\n",
      "  24 166 148   9  75 182  99 142   3 152 145 114 191   7 186  78  61  62\n",
      "  96 102 104 187 140  73   6 174 162 123 120 128  42  19 127  11 116 106\n",
      " 167  85  41 133 172  93 135  38 125 157  68  18 183  87 129  95  25 103\n",
      "   4 134  37  46  33 164  53  40  86 165  47  28  97  80  58 132   0 194\n",
      "  50 100  36 192 170 161  64  72  32 117  29  21  69  88  14 146 168  83\n",
      " 130 124 160  13 179 126  52  65 147  79 173 131  71 108  44  77 149 111\n",
      " 158 115]\n"
     ]
    }
   ],
   "source": [
    "permutationTrain = np.random.permutation(dataX.shape[0])\n",
    "print(permutationTrain)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [],
   "source": [
    "vfoldSize = int(dataX.shape[0]/100*20)\n",
    "\n",
    "xTest = dataX[0:vfoldSize]\n",
    "yTest = dataY[0:vfoldSize]\n",
    "\n",
    "xTrain = dataX[vfoldSize:dataX.shape[0]]\n",
    "yTrain = dataY[vfoldSize:dataY.shape[0]]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [],
   "source": [
    "model = keras.Sequential()\n",
    "model.add(keras.layers.Dense(32, input_shape =(6*SAMPLES_PER_GESTURE,), activation='relu'))\n",
    "model.add(keras.layers.Dense(16, activation='relu'))\n",
    "model.add(keras.layers.Dense(2, activation='softmax'))\n",
    "adam = keras.optimizers.Adam()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Model: \"sequential\"\n",
      "_________________________________________________________________\n",
      "Layer (type)                 Output Shape              Param #   \n",
      "=================================================================\n",
      "dense (Dense)                (None, 32)                5792      \n",
      "_________________________________________________________________\n",
      "dense_1 (Dense)              (None, 16)                528       \n",
      "_________________________________________________________________\n",
      "dense_2 (Dense)              (None, 2)                 34        \n",
      "=================================================================\n",
      "Total params: 6,354\n",
      "Trainable params: 6,354\n",
      "Non-trainable params: 0\n",
      "_________________________________________________________________\n"
     ]
    }
   ],
   "source": [
    "model.compile(loss='sparse_categorical_crossentropy',\n",
    "              optimizer=adam,\n",
    "              metrics=['sparse_categorical_accuracy'])\n",
    "model.summary()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {
    "collapsed": true,
    "jupyter": {
     "outputs_hidden": true
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Train on 160 samples, validate on 40 samples\n",
      "Epoch 1/200\n",
      "160/160 [==============================] - 2s 10ms/sample - loss: 0.2666 - sparse_categorical_accuracy: 0.9688 - val_loss: 0.1580 - val_sparse_categorical_accuracy: 1.0000\n",
      "Epoch 2/200\n",
      "160/160 [==============================] - 0s 3ms/sample - loss: 0.0451 - sparse_categorical_accuracy: 0.9937 - val_loss: 0.0292 - val_sparse_categorical_accuracy: 1.0000\n",
      "Epoch 3/200\n",
      "160/160 [==============================] - 1s 3ms/sample - loss: 0.0407 - sparse_categorical_accuracy: 0.9812 - val_loss: 0.0107 - val_sparse_categorical_accuracy: 1.0000\n",
      "Epoch 4/200\n",
      "160/160 [==============================] - 1s 3ms/sample - loss: 0.0427 - sparse_categorical_accuracy: 0.9812 - val_loss: 0.0117 - val_sparse_categorical_accuracy: 1.0000\n",
      "Epoch 5/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 0.0072 - sparse_categorical_accuracy: 1.0000 - val_loss: 0.0413 - val_sparse_categorical_accuracy: 1.0000\n",
      "Epoch 6/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 0.0082 - sparse_categorical_accuracy: 1.0000 - val_loss: 0.0330 - val_sparse_categorical_accuracy: 1.0000\n",
      "Epoch 7/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 0.0045 - sparse_categorical_accuracy: 1.0000 - val_loss: 0.0081 - val_sparse_categorical_accuracy: 1.0000\n",
      "Epoch 8/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 0.0092 - sparse_categorical_accuracy: 1.0000 - val_loss: 0.0031 - val_sparse_categorical_accuracy: 1.0000\n",
      "Epoch 9/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 0.0031 - sparse_categorical_accuracy: 1.0000 - val_loss: 0.0045 - val_sparse_categorical_accuracy: 1.0000\n",
      "Epoch 10/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 0.0035 - sparse_categorical_accuracy: 1.0000 - val_loss: 0.0069 - val_sparse_categorical_accuracy: 1.0000\n",
      "Epoch 11/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 0.0015 - sparse_categorical_accuracy: 1.0000 - val_loss: 0.0062 - val_sparse_categorical_accuracy: 1.0000\n",
      "Epoch 12/200\n",
      "160/160 [==============================] - 1s 3ms/sample - loss: 0.0010 - sparse_categorical_accuracy: 1.0000 - val_loss: 0.0024 - val_sparse_categorical_accuracy: 1.0000\n",
      "Epoch 13/200\n",
      "160/160 [==============================] - 1s 3ms/sample - loss: 0.0010 - sparse_categorical_accuracy: 1.0000 - val_loss: 0.0347 - val_sparse_categorical_accuracy: 1.0000\n",
      "Epoch 14/200\n",
      "160/160 [==============================] - 0s 3ms/sample - loss: 8.2917e-04 - sparse_categorical_accuracy: 1.0000 - val_loss: 0.0027 - val_sparse_categorical_accuracy: 1.0000\n",
      "Epoch 15/200\n",
      "160/160 [==============================] - 1s 3ms/sample - loss: 0.0011 - sparse_categorical_accuracy: 1.0000 - val_loss: 0.0025 - val_sparse_categorical_accuracy: 1.0000\n",
      "Epoch 16/200\n",
      "160/160 [==============================] - 0s 3ms/sample - loss: 7.1433e-04 - sparse_categorical_accuracy: 1.0000 - val_loss: 0.0031 - val_sparse_categorical_accuracy: 1.0000\n",
      "Epoch 17/200\n",
      "160/160 [==============================] - 1s 3ms/sample - loss: 5.7031e-04 - sparse_categorical_accuracy: 1.0000 - val_loss: 0.0071 - val_sparse_categorical_accuracy: 1.0000\n",
      "Epoch 18/200\n",
      "160/160 [==============================] - 1s 3ms/sample - loss: 4.1529e-04 - sparse_categorical_accuracy: 1.0000 - val_loss: 0.0051 - val_sparse_categorical_accuracy: 1.0000\n",
      "Epoch 19/200\n",
      "160/160 [==============================] - 1s 3ms/sample - loss: 3.9328e-04 - sparse_categorical_accuracy: 1.0000 - val_loss: 0.0028 - val_sparse_categorical_accuracy: 1.0000\n",
      "Epoch 20/200\n",
      "160/160 [==============================] - 0s 3ms/sample - loss: 3.6300e-04 - sparse_categorical_accuracy: 1.0000 - val_loss: 0.0065 - val_sparse_categorical_accuracy: 1.0000\n",
      "Epoch 21/200\n",
      "160/160 [==============================] - 0s 3ms/sample - loss: 2.5451e-04 - sparse_categorical_accuracy: 1.0000 - val_loss: 0.0013 - val_sparse_categorical_accuracy: 1.0000\n",
      "Epoch 22/200\n",
      "160/160 [==============================] - 1s 3ms/sample - loss: 3.2866e-04 - sparse_categorical_accuracy: 1.0000 - val_loss: 0.0024 - val_sparse_categorical_accuracy: 1.0000\n",
      "Epoch 23/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 2.0145e-04 - sparse_categorical_accuracy: 1.0000 - val_loss: 0.0036 - val_sparse_categorical_accuracy: 1.0000\n",
      "Epoch 24/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 2.0439e-04 - sparse_categorical_accuracy: 1.0000 - val_loss: 0.0026 - val_sparse_categorical_accuracy: 1.0000\n",
      "Epoch 25/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 1.5319e-04 - sparse_categorical_accuracy: 1.0000 - val_loss: 0.0011 - val_sparse_categorical_accuracy: 1.0000\n",
      "Epoch 26/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 1.7909e-04 - sparse_categorical_accuracy: 1.0000 - val_loss: 0.0010 - val_sparse_categorical_accuracy: 1.0000\n",
      "Epoch 27/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 1.6295e-04 - sparse_categorical_accuracy: 1.0000 - val_loss: 0.0013 - val_sparse_categorical_accuracy: 1.0000\n",
      "Epoch 28/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 1.1734e-04 - sparse_categorical_accuracy: 1.0000 - val_loss: 0.0010 - val_sparse_categorical_accuracy: 1.0000\n",
      "Epoch 29/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 9.9064e-05 - sparse_categorical_accuracy: 1.0000 - val_loss: 0.0023 - val_sparse_categorical_accuracy: 1.0000\n",
      "Epoch 30/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 1.0330e-04 - sparse_categorical_accuracy: 1.0000 - val_loss: 0.0015 - val_sparse_categorical_accuracy: 1.0000\n",
      "Epoch 31/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 8.7958e-05 - sparse_categorical_accuracy: 1.0000 - val_loss: 9.8860e-04 - val_sparse_categorical_accuracy: 1.0000\n",
      "Epoch 32/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 6.8264e-05 - sparse_categorical_accuracy: 1.0000 - val_loss: 0.0016 - val_sparse_categorical_accuracy: 1.0000\n",
      "Epoch 33/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 5.7921e-05 - sparse_categorical_accuracy: 1.0000 - val_loss: 0.0010 - val_sparse_categorical_accuracy: 1.0000\n",
      "Epoch 34/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 6.7215e-05 - sparse_categorical_accuracy: 1.0000 - val_loss: 0.0011 - val_sparse_categorical_accuracy: 1.0000\n",
      "Epoch 35/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 5.5520e-05 - sparse_categorical_accuracy: 1.0000 - val_loss: 0.0017 - val_sparse_categorical_accuracy: 1.0000\n",
      "Epoch 36/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 4.1532e-05 - sparse_categorical_accuracy: 1.0000 - val_loss: 5.8525e-04 - val_sparse_categorical_accuracy: 1.0000\n",
      "Epoch 37/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 4.4577e-05 - sparse_categorical_accuracy: 1.0000 - val_loss: 0.0031 - val_sparse_categorical_accuracy: 1.0000\n",
      "Epoch 38/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 4.7638e-05 - sparse_categorical_accuracy: 1.0000 - val_loss: 0.0019 - val_sparse_categorical_accuracy: 1.0000\n",
      "Epoch 39/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 3.1722e-05 - sparse_categorical_accuracy: 1.0000 - val_loss: 7.2286e-04 - val_sparse_categorical_accuracy: 1.0000\n",
      "Epoch 40/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 3.8543e-05 - sparse_categorical_accuracy: 1.0000 - val_loss: 0.0016 - val_sparse_categorical_accuracy: 1.0000\n",
      "Epoch 41/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 3.1173e-05 - sparse_categorical_accuracy: 1.0000 - val_loss: 7.7090e-04 - val_sparse_categorical_accuracy: 1.0000\n",
      "Epoch 42/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 2.8284e-05 - sparse_categorical_accuracy: 1.0000 - val_loss: 8.0784e-04 - val_sparse_categorical_accuracy: 1.0000\n",
      "Epoch 43/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 2.0396e-05 - sparse_categorical_accuracy: 1.0000 - val_loss: 4.4104e-04 - val_sparse_categorical_accuracy: 1.0000\n",
      "Epoch 44/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 2.3300e-05 - sparse_categorical_accuracy: 1.0000 - val_loss: 0.0019 - val_sparse_categorical_accuracy: 1.0000\n",
      "Epoch 45/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 1.8102e-05 - sparse_categorical_accuracy: 1.0000 - val_loss: 4.9491e-04 - val_sparse_categorical_accuracy: 1.0000\n",
      "Epoch 46/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 2.2368e-05 - sparse_categorical_accuracy: 1.0000 - val_loss: 0.0011 - val_sparse_categorical_accuracy: 1.0000\n",
      "Epoch 47/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 1.3645e-05 - sparse_categorical_accuracy: 1.0000 - val_loss: 4.5894e-04 - val_sparse_categorical_accuracy: 1.0000\n",
      "Epoch 48/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 1.3665e-05 - sparse_categorical_accuracy: 1.0000 - val_loss: 9.1776e-04 - val_sparse_categorical_accuracy: 1.0000\n",
      "Epoch 49/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 1.2256e-05 - sparse_categorical_accuracy: 1.0000 - val_loss: 4.7673e-04 - val_sparse_categorical_accuracy: 1.0000\n",
      "Epoch 50/200\n",
      "160/160 [==============================] - 1s 3ms/sample - loss: 1.2433e-05 - sparse_categorical_accuracy: 1.0000 - val_loss: 6.1617e-04 - val_sparse_categorical_accuracy: 1.0000\n",
      "Epoch 51/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 1.0236e-05 - sparse_categorical_accuracy: 1.0000 - val_loss: 8.6820e-04 - val_sparse_categorical_accuracy: 1.0000\n",
      "Epoch 52/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 9.2715e-06 - sparse_categorical_accuracy: 1.0000 - val_loss: 4.7418e-04 - val_sparse_categorical_accuracy: 1.0000\n",
      "Epoch 53/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 8.5964e-06 - sparse_categorical_accuracy: 1.0000 - val_loss: 3.9387e-04 - val_sparse_categorical_accuracy: 1.0000\n",
      "Epoch 54/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 9.2045e-06 - sparse_categorical_accuracy: 1.0000 - val_loss: 6.3491e-04 - val_sparse_categorical_accuracy: 1.0000\n",
      "Epoch 55/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 6.4452e-06 - sparse_categorical_accuracy: 1.0000 - val_loss: 2.9818e-04 - val_sparse_categorical_accuracy: 1.0000\n",
      "Epoch 56/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 6.8496e-06 - sparse_categorical_accuracy: 1.0000 - val_loss: 4.8698e-04 - val_sparse_categorical_accuracy: 1.0000\n",
      "Epoch 57/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 8.0707e-06 - sparse_categorical_accuracy: 1.0000 - val_loss: 6.0367e-04 - val_sparse_categorical_accuracy: 1.0000\n",
      "Epoch 58/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 6.5416e-06 - sparse_categorical_accuracy: 1.0000 - val_loss: 6.4273e-04 - val_sparse_categorical_accuracy: 1.0000\n",
      "Epoch 59/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 4.2302e-06 - sparse_categorical_accuracy: 1.0000 - val_loss: 1.7672e-04 - val_sparse_categorical_accuracy: 1.0000\n",
      "Epoch 60/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 4.2250e-06 - sparse_categorical_accuracy: 1.0000 - val_loss: 6.1135e-04 - val_sparse_categorical_accuracy: 1.0000\n",
      "Epoch 61/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 4.1267e-06 - sparse_categorical_accuracy: 1.0000 - val_loss: 3.8677e-04 - val_sparse_categorical_accuracy: 1.0000\n",
      "Epoch 62/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 3.9099e-06 - sparse_categorical_accuracy: 1.0000 - val_loss: 4.7286e-04 - val_sparse_categorical_accuracy: 1.0000\n",
      "Epoch 63/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 2.9354e-06 - sparse_categorical_accuracy: 1.0000 - val_loss: 2.1337e-04 - val_sparse_categorical_accuracy: 1.0000\n",
      "Epoch 64/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 3.0248e-06 - sparse_categorical_accuracy: 1.0000 - val_loss: 5.9373e-04 - val_sparse_categorical_accuracy: 1.0000\n",
      "Epoch 65/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 2.6508e-06 - sparse_categorical_accuracy: 1.0000 - val_loss: 2.5338e-04 - val_sparse_categorical_accuracy: 1.0000\n",
      "Epoch 66/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 2.5279e-06 - sparse_categorical_accuracy: 1.0000 - val_loss: 2.4574e-04 - val_sparse_categorical_accuracy: 1.0000\n",
      "Epoch 67/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 2.2977e-06 - sparse_categorical_accuracy: 1.0000 - val_loss: 2.2696e-04 - val_sparse_categorical_accuracy: 1.0000\n",
      "Epoch 68/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 2.1330e-06 - sparse_categorical_accuracy: 1.0000 - val_loss: 2.0943e-04 - val_sparse_categorical_accuracy: 1.0000\n",
      "Epoch 69/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 1.9780e-06 - sparse_categorical_accuracy: 1.0000 - val_loss: 7.6517e-04 - val_sparse_categorical_accuracy: 1.0000\n",
      "Epoch 70/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 2.8877e-06 - sparse_categorical_accuracy: 1.0000 - val_loss: 2.2864e-04 - val_sparse_categorical_accuracy: 1.0000\n",
      "Epoch 71/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 1.4953e-06 - sparse_categorical_accuracy: 1.0000 - val_loss: 2.5242e-04 - val_sparse_categorical_accuracy: 1.0000\n",
      "Epoch 72/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 1.3590e-06 - sparse_categorical_accuracy: 1.0000 - val_loss: 2.8585e-04 - val_sparse_categorical_accuracy: 1.0000\n",
      "Epoch 73/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 1.2226e-06 - sparse_categorical_accuracy: 1.0000 - val_loss: 2.6476e-04 - val_sparse_categorical_accuracy: 1.0000\n",
      "Epoch 74/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 1.0319e-06 - sparse_categorical_accuracy: 1.0000 - val_loss: 1.7063e-04 - val_sparse_categorical_accuracy: 1.0000\n",
      "Epoch 75/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 1.0460e-06 - sparse_categorical_accuracy: 1.0000 - val_loss: 3.3870e-04 - val_sparse_categorical_accuracy: 1.0000\n",
      "Epoch 76/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 8.7469e-07 - sparse_categorical_accuracy: 1.0000 - val_loss: 1.3967e-04 - val_sparse_categorical_accuracy: 1.0000\n",
      "Epoch 77/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 9.1418e-07 - sparse_categorical_accuracy: 1.0000 - val_loss: 3.7248e-04 - val_sparse_categorical_accuracy: 1.0000\n",
      "Epoch 78/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 8.5606e-07 - sparse_categorical_accuracy: 1.0000 - val_loss: 1.4694e-04 - val_sparse_categorical_accuracy: 1.0000\n",
      "Epoch 79/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 8.3073e-07 - sparse_categorical_accuracy: 1.0000 - val_loss: 3.9176e-04 - val_sparse_categorical_accuracy: 1.0000\n",
      "Epoch 80/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 6.6086e-07 - sparse_categorical_accuracy: 1.0000 - val_loss: 1.1099e-04 - val_sparse_categorical_accuracy: 1.0000\n",
      "Epoch 81/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 7.2270e-07 - sparse_categorical_accuracy: 1.0000 - val_loss: 1.3454e-04 - val_sparse_categorical_accuracy: 1.0000\n",
      "Epoch 82/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 5.4687e-07 - sparse_categorical_accuracy: 1.0000 - val_loss: 2.3891e-04 - val_sparse_categorical_accuracy: 1.0000\n",
      "Epoch 83/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 5.0589e-07 - sparse_categorical_accuracy: 1.0000 - val_loss: 1.7304e-04 - val_sparse_categorical_accuracy: 1.0000\n",
      "Epoch 84/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 4.3660e-07 - sparse_categorical_accuracy: 1.0000 - val_loss: 1.0052e-04 - val_sparse_categorical_accuracy: 1.0000\n",
      "Epoch 85/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 4.1947e-07 - sparse_categorical_accuracy: 1.0000 - val_loss: 9.4363e-05 - val_sparse_categorical_accuracy: 1.0000\n",
      "Epoch 86/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 4.3958e-07 - sparse_categorical_accuracy: 1.0000 - val_loss: 1.7122e-04 - val_sparse_categorical_accuracy: 1.0000\n",
      "Epoch 87/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 3.3527e-07 - sparse_categorical_accuracy: 1.0000 - val_loss: 1.5089e-04 - val_sparse_categorical_accuracy: 1.0000\n",
      "Epoch 88/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 3.0473e-07 - sparse_categorical_accuracy: 1.0000 - val_loss: 1.1146e-04 - val_sparse_categorical_accuracy: 1.0000\n",
      "Epoch 89/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 2.8312e-07 - sparse_categorical_accuracy: 1.0000 - val_loss: 2.1050e-04 - val_sparse_categorical_accuracy: 1.0000\n",
      "Epoch 90/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 2.9728e-07 - sparse_categorical_accuracy: 1.0000 - val_loss: 1.8478e-04 - val_sparse_categorical_accuracy: 1.0000\n",
      "Epoch 91/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 2.4587e-07 - sparse_categorical_accuracy: 1.0000 - val_loss: 1.6236e-04 - val_sparse_categorical_accuracy: 1.0000\n",
      "Epoch 92/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 2.0713e-07 - sparse_categorical_accuracy: 1.0000 - val_loss: 6.4247e-05 - val_sparse_categorical_accuracy: 1.0000\n",
      "Epoch 93/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 2.4363e-07 - sparse_categorical_accuracy: 1.0000 - val_loss: 1.6395e-04 - val_sparse_categorical_accuracy: 1.0000\n",
      "Epoch 94/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 2.0117e-07 - sparse_categorical_accuracy: 1.0000 - val_loss: 1.3631e-04 - val_sparse_categorical_accuracy: 1.0000\n",
      "Epoch 95/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 1.6168e-07 - sparse_categorical_accuracy: 1.0000 - val_loss: 1.0894e-04 - val_sparse_categorical_accuracy: 1.0000\n",
      "Epoch 96/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 1.6466e-07 - sparse_categorical_accuracy: 1.0000 - val_loss: 7.5830e-05 - val_sparse_categorical_accuracy: 1.0000\n",
      "Epoch 97/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 1.4529e-07 - sparse_categorical_accuracy: 1.0000 - val_loss: 4.6845e-05 - val_sparse_categorical_accuracy: 1.0000\n",
      "Epoch 98/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 1.5870e-07 - sparse_categorical_accuracy: 1.0000 - val_loss: 1.7049e-04 - val_sparse_categorical_accuracy: 1.0000\n",
      "Epoch 99/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 1.1474e-07 - sparse_categorical_accuracy: 1.0000 - val_loss: 5.4071e-05 - val_sparse_categorical_accuracy: 1.0000\n",
      "Epoch 100/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 1.2219e-07 - sparse_categorical_accuracy: 1.0000 - val_loss: 1.0882e-04 - val_sparse_categorical_accuracy: 1.0000\n",
      "Epoch 101/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 8.7917e-08 - sparse_categorical_accuracy: 1.0000 - val_loss: 8.9983e-05 - val_sparse_categorical_accuracy: 1.0000\n",
      "Epoch 102/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 8.6427e-08 - sparse_categorical_accuracy: 1.0000 - val_loss: 6.1409e-05 - val_sparse_categorical_accuracy: 1.0000\n",
      "Epoch 103/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 8.4191e-08 - sparse_categorical_accuracy: 1.0000 - val_loss: 6.0840e-05 - val_sparse_categorical_accuracy: 1.0000\n",
      "Epoch 104/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 7.2271e-08 - sparse_categorical_accuracy: 1.0000 - val_loss: 4.2772e-05 - val_sparse_categorical_accuracy: 1.0000\n",
      "Epoch 105/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 7.4506e-08 - sparse_categorical_accuracy: 1.0000 - val_loss: 1.4614e-04 - val_sparse_categorical_accuracy: 1.0000\n",
      "Epoch 106/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 6.8545e-08 - sparse_categorical_accuracy: 1.0000 - val_loss: 6.9006e-05 - val_sparse_categorical_accuracy: 1.0000\n",
      "Epoch 107/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 5.7369e-08 - sparse_categorical_accuracy: 1.0000 - val_loss: 6.1229e-05 - val_sparse_categorical_accuracy: 1.0000\n",
      "Epoch 108/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 5.3644e-08 - sparse_categorical_accuracy: 1.0000 - val_loss: 9.1755e-05 - val_sparse_categorical_accuracy: 1.0000\n",
      "Epoch 109/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 5.0664e-08 - sparse_categorical_accuracy: 1.0000 - val_loss: 8.9826e-05 - val_sparse_categorical_accuracy: 1.0000\n",
      "Epoch 110/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 3.7253e-08 - sparse_categorical_accuracy: 1.0000 - val_loss: 3.1526e-05 - val_sparse_categorical_accuracy: 1.0000\n",
      "Epoch 111/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 5.3644e-08 - sparse_categorical_accuracy: 1.0000 - val_loss: 6.8056e-05 - val_sparse_categorical_accuracy: 1.0000\n",
      "Epoch 112/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 2.9802e-08 - sparse_categorical_accuracy: 1.0000 - val_loss: 3.4027e-05 - val_sparse_categorical_accuracy: 1.0000\n",
      "Epoch 113/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 3.2037e-08 - sparse_categorical_accuracy: 1.0000 - val_loss: 3.9199e-05 - val_sparse_categorical_accuracy: 1.0000\n",
      "Epoch 114/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 3.1292e-08 - sparse_categorical_accuracy: 1.0000 - val_loss: 3.6749e-05 - val_sparse_categorical_accuracy: 1.0000\n",
      "Epoch 115/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 2.8312e-08 - sparse_categorical_accuracy: 1.0000 - val_loss: 4.6230e-05 - val_sparse_categorical_accuracy: 1.0000\n",
      "Epoch 116/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 2.3097e-08 - sparse_categorical_accuracy: 1.0000 - val_loss: 7.0798e-05 - val_sparse_categorical_accuracy: 1.0000\n",
      "Epoch 117/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 2.1607e-08 - sparse_categorical_accuracy: 1.0000 - val_loss: 3.9130e-05 - val_sparse_categorical_accuracy: 1.0000\n",
      "Epoch 118/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 1.8626e-08 - sparse_categorical_accuracy: 1.0000 - val_loss: 3.1413e-05 - val_sparse_categorical_accuracy: 1.0000\n",
      "Epoch 119/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 2.0117e-08 - sparse_categorical_accuracy: 1.0000 - val_loss: 5.0328e-05 - val_sparse_categorical_accuracy: 1.0000\n",
      "Epoch 120/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 1.8626e-08 - sparse_categorical_accuracy: 1.0000 - val_loss: 7.1939e-05 - val_sparse_categorical_accuracy: 1.0000\n",
      "Epoch 121/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 1.4156e-08 - sparse_categorical_accuracy: 1.0000 - val_loss: 2.6839e-05 - val_sparse_categorical_accuracy: 1.0000\n",
      "Epoch 122/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 1.5646e-08 - sparse_categorical_accuracy: 1.0000 - val_loss: 4.5494e-05 - val_sparse_categorical_accuracy: 1.0000\n",
      "Epoch 123/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 1.2666e-08 - sparse_categorical_accuracy: 1.0000 - val_loss: 4.0315e-05 - val_sparse_categorical_accuracy: 1.0000\n",
      "Epoch 124/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 1.0431e-08 - sparse_categorical_accuracy: 1.0000 - val_loss: 3.5655e-05 - val_sparse_categorical_accuracy: 1.0000\n",
      "Epoch 125/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 1.0431e-08 - sparse_categorical_accuracy: 1.0000 - val_loss: 2.5966e-05 - val_sparse_categorical_accuracy: 1.0000\n",
      "Epoch 126/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 1.0431e-08 - sparse_categorical_accuracy: 1.0000 - val_loss: 6.1039e-05 - val_sparse_categorical_accuracy: 1.0000\n",
      "Epoch 127/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 1.0431e-08 - sparse_categorical_accuracy: 1.0000 - val_loss: 2.7658e-05 - val_sparse_categorical_accuracy: 1.0000\n",
      "Epoch 128/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 8.9407e-09 - sparse_categorical_accuracy: 1.0000 - val_loss: 3.6974e-05 - val_sparse_categorical_accuracy: 1.0000\n",
      "Epoch 129/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 8.9407e-09 - sparse_categorical_accuracy: 1.0000 - val_loss: 2.4653e-05 - val_sparse_categorical_accuracy: 1.0000\n",
      "Epoch 130/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 7.4506e-09 - sparse_categorical_accuracy: 1.0000 - val_loss: 3.4027e-05 - val_sparse_categorical_accuracy: 1.0000\n",
      "Epoch 131/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 5.9605e-09 - sparse_categorical_accuracy: 1.0000 - val_loss: 3.2779e-05 - val_sparse_categorical_accuracy: 1.0000\n",
      "Epoch 132/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 5.2154e-09 - sparse_categorical_accuracy: 1.0000 - val_loss: 3.3753e-05 - val_sparse_categorical_accuracy: 1.0000\n",
      "Epoch 133/200\n",
      "160/160 [==============================] - 1s 3ms/sample - loss: 5.2154e-09 - sparse_categorical_accuracy: 1.0000 - val_loss: 2.2303e-05 - val_sparse_categorical_accuracy: 1.0000\n",
      "Epoch 134/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 4.4703e-09 - sparse_categorical_accuracy: 1.0000 - val_loss: 1.6837e-05 - val_sparse_categorical_accuracy: 1.0000\n",
      "Epoch 135/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 5.2154e-09 - sparse_categorical_accuracy: 1.0000 - val_loss: 2.4849e-05 - val_sparse_categorical_accuracy: 1.0000\n",
      "Epoch 136/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 5.9605e-09 - sparse_categorical_accuracy: 1.0000 - val_loss: 2.8024e-05 - val_sparse_categorical_accuracy: 1.0000\n",
      "Epoch 137/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 3.7253e-09 - sparse_categorical_accuracy: 1.0000 - val_loss: 2.6865e-05 - val_sparse_categorical_accuracy: 1.0000\n",
      "Epoch 138/200\n",
      "160/160 [==============================] - 1s 3ms/sample - loss: 2.9802e-09 - sparse_categorical_accuracy: 1.0000 - val_loss: 2.2747e-05 - val_sparse_categorical_accuracy: 1.0000\n",
      "Epoch 139/200\n",
      "160/160 [==============================] - 0s 3ms/sample - loss: 2.9802e-09 - sparse_categorical_accuracy: 1.0000 - val_loss: 1.4418e-05 - val_sparse_categorical_accuracy: 1.0000\n",
      "Epoch 140/200\n",
      "160/160 [==============================] - 0s 3ms/sample - loss: 2.9802e-09 - sparse_categorical_accuracy: 1.0000 - val_loss: 1.2101e-05 - val_sparse_categorical_accuracy: 1.0000\n",
      "Epoch 141/200\n",
      "160/160 [==============================] - 0s 3ms/sample - loss: 2.2352e-09 - sparse_categorical_accuracy: 1.0000 - val_loss: 1.7171e-05 - val_sparse_categorical_accuracy: 1.0000\n",
      "Epoch 142/200\n",
      "160/160 [==============================] - 1s 3ms/sample - loss: 2.2352e-09 - sparse_categorical_accuracy: 1.0000 - val_loss: 2.3467e-05 - val_sparse_categorical_accuracy: 1.0000\n",
      "Epoch 143/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 2.2352e-09 - sparse_categorical_accuracy: 1.0000 - val_loss: 1.9613e-05 - val_sparse_categorical_accuracy: 1.0000\n",
      "Epoch 144/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 7.4506e-10 - sparse_categorical_accuracy: 1.0000 - val_loss: 3.4750e-05 - val_sparse_categorical_accuracy: 1.0000\n",
      "Epoch 145/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 2.2352e-09 - sparse_categorical_accuracy: 1.0000 - val_loss: 2.2833e-05 - val_sparse_categorical_accuracy: 1.0000\n",
      "Epoch 146/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 1.4901e-09 - sparse_categorical_accuracy: 1.0000 - val_loss: 1.8201e-05 - val_sparse_categorical_accuracy: 1.0000\n",
      "Epoch 147/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 0.0000e+00 - sparse_categorical_accuracy: 1.0000 - val_loss: 1.6468e-05 - val_sparse_categorical_accuracy: 1.0000\n",
      "Epoch 148/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 1.4901e-09 - sparse_categorical_accuracy: 1.0000 - val_loss: 1.4668e-05 - val_sparse_categorical_accuracy: 1.0000\n",
      "Epoch 149/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 1.4901e-09 - sparse_categorical_accuracy: 1.0000 - val_loss: 1.7090e-05 - val_sparse_categorical_accuracy: 1.0000\n",
      "Epoch 150/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 7.4506e-10 - sparse_categorical_accuracy: 1.0000 - val_loss: 2.6573e-05 - val_sparse_categorical_accuracy: 1.0000\n",
      "Epoch 151/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 0.0000e+00 - sparse_categorical_accuracy: 1.0000 - val_loss: 1.6235e-05 - val_sparse_categorical_accuracy: 1.0000\n",
      "Epoch 152/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 0.0000e+00 - sparse_categorical_accuracy: 1.0000 - val_loss: 1.5887e-05 - val_sparse_categorical_accuracy: 1.0000\n",
      "Epoch 153/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 1.4901e-09 - sparse_categorical_accuracy: 1.0000 - val_loss: 1.3593e-05 - val_sparse_categorical_accuracy: 1.0000\n",
      "Epoch 154/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 0.0000e+00 - sparse_categorical_accuracy: 1.0000 - val_loss: 1.1344e-05 - val_sparse_categorical_accuracy: 1.0000\n",
      "Epoch 155/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 0.0000e+00 - sparse_categorical_accuracy: 1.0000 - val_loss: 1.3900e-05 - val_sparse_categorical_accuracy: 1.0000\n",
      "Epoch 156/200\n",
      "160/160 [==============================] - 1s 3ms/sample - loss: 0.0000e+00 - sparse_categorical_accuracy: 1.0000 - val_loss: 1.5768e-05 - val_sparse_categorical_accuracy: 1.0000\n",
      "Epoch 157/200\n",
      "160/160 [==============================] - 1s 3ms/sample - loss: 0.0000e+00 - sparse_categorical_accuracy: 1.0000 - val_loss: 1.3212e-05 - val_sparse_categorical_accuracy: 1.0000\n",
      "Epoch 158/200\n",
      "160/160 [==============================] - 0s 3ms/sample - loss: 0.0000e+00 - sparse_categorical_accuracy: 1.0000 - val_loss: 1.1797e-05 - val_sparse_categorical_accuracy: 1.0000\n",
      "Epoch 159/200\n",
      "160/160 [==============================] - 0s 3ms/sample - loss: 0.0000e+00 - sparse_categorical_accuracy: 1.0000 - val_loss: 1.1400e-05 - val_sparse_categorical_accuracy: 1.0000\n",
      "Epoch 160/200\n",
      "160/160 [==============================] - 0s 3ms/sample - loss: 0.0000e+00 - sparse_categorical_accuracy: 1.0000 - val_loss: 1.5908e-05 - val_sparse_categorical_accuracy: 1.0000\n",
      "Epoch 161/200\n",
      "160/160 [==============================] - 1s 3ms/sample - loss: 0.0000e+00 - sparse_categorical_accuracy: 1.0000 - val_loss: 1.2866e-05 - val_sparse_categorical_accuracy: 1.0000\n",
      "Epoch 162/200\n",
      "160/160 [==============================] - 0s 3ms/sample - loss: 0.0000e+00 - sparse_categorical_accuracy: 1.0000 - val_loss: 1.3179e-05 - val_sparse_categorical_accuracy: 1.0000\n",
      "Epoch 163/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 0.0000e+00 - sparse_categorical_accuracy: 1.0000 - val_loss: 1.1138e-05 - val_sparse_categorical_accuracy: 1.0000\n",
      "Epoch 164/200\n",
      "160/160 [==============================] - 1s 3ms/sample - loss: 0.0000e+00 - sparse_categorical_accuracy: 1.0000 - val_loss: 1.3423e-05 - val_sparse_categorical_accuracy: 1.0000\n",
      "Epoch 165/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 0.0000e+00 - sparse_categorical_accuracy: 1.0000 - val_loss: 1.3620e-05 - val_sparse_categorical_accuracy: 1.0000\n",
      "Epoch 166/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 0.0000e+00 - sparse_categorical_accuracy: 1.0000 - val_loss: 1.2017e-05 - val_sparse_categorical_accuracy: 1.0000\n",
      "Epoch 167/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 0.0000e+00 - sparse_categorical_accuracy: 1.0000 - val_loss: 1.1415e-05 - val_sparse_categorical_accuracy: 1.0000\n",
      "Epoch 168/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 0.0000e+00 - sparse_categorical_accuracy: 1.0000 - val_loss: 1.2196e-05 - val_sparse_categorical_accuracy: 1.0000\n",
      "Epoch 169/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 0.0000e+00 - sparse_categorical_accuracy: 1.0000 - val_loss: 1.4934e-05 - val_sparse_categorical_accuracy: 1.0000\n",
      "Epoch 170/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 0.0000e+00 - sparse_categorical_accuracy: 1.0000 - val_loss: 1.1910e-05 - val_sparse_categorical_accuracy: 1.0000\n",
      "Epoch 171/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 0.0000e+00 - sparse_categorical_accuracy: 1.0000 - val_loss: 1.1457e-05 - val_sparse_categorical_accuracy: 1.0000\n",
      "Epoch 172/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 0.0000e+00 - sparse_categorical_accuracy: 1.0000 - val_loss: 9.4162e-06 - val_sparse_categorical_accuracy: 1.0000\n",
      "Epoch 173/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 0.0000e+00 - sparse_categorical_accuracy: 1.0000 - val_loss: 1.2726e-05 - val_sparse_categorical_accuracy: 1.0000\n",
      "Epoch 174/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 0.0000e+00 - sparse_categorical_accuracy: 1.0000 - val_loss: 1.1308e-05 - val_sparse_categorical_accuracy: 1.0000\n",
      "Epoch 175/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 0.0000e+00 - sparse_categorical_accuracy: 1.0000 - val_loss: 1.2252e-05 - val_sparse_categorical_accuracy: 1.0000\n",
      "Epoch 176/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 0.0000e+00 - sparse_categorical_accuracy: 1.0000 - val_loss: 1.2357e-05 - val_sparse_categorical_accuracy: 1.0000\n",
      "Epoch 177/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 0.0000e+00 - sparse_categorical_accuracy: 1.0000 - val_loss: 1.0235e-05 - val_sparse_categorical_accuracy: 1.0000\n",
      "Epoch 178/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 0.0000e+00 - sparse_categorical_accuracy: 1.0000 - val_loss: 1.0802e-05 - val_sparse_categorical_accuracy: 1.0000\n",
      "Epoch 179/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 0.0000e+00 - sparse_categorical_accuracy: 1.0000 - val_loss: 9.0825e-06 - val_sparse_categorical_accuracy: 1.0000\n",
      "Epoch 180/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 0.0000e+00 - sparse_categorical_accuracy: 1.0000 - val_loss: 8.7994e-06 - val_sparse_categorical_accuracy: 1.0000\n",
      "Epoch 181/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 0.0000e+00 - sparse_categorical_accuracy: 1.0000 - val_loss: 9.9793e-06 - val_sparse_categorical_accuracy: 1.0000\n",
      "Epoch 182/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 0.0000e+00 - sparse_categorical_accuracy: 1.0000 - val_loss: 9.6694e-06 - val_sparse_categorical_accuracy: 1.0000\n",
      "Epoch 183/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 0.0000e+00 - sparse_categorical_accuracy: 1.0000 - val_loss: 1.0447e-05 - val_sparse_categorical_accuracy: 1.0000\n",
      "Epoch 184/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 0.0000e+00 - sparse_categorical_accuracy: 1.0000 - val_loss: 1.0289e-05 - val_sparse_categorical_accuracy: 1.0000\n",
      "Epoch 185/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 0.0000e+00 - sparse_categorical_accuracy: 1.0000 - val_loss: 8.9812e-06 - val_sparse_categorical_accuracy: 1.0000\n",
      "Epoch 186/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 0.0000e+00 - sparse_categorical_accuracy: 1.0000 - val_loss: 9.4042e-06 - val_sparse_categorical_accuracy: 1.0000\n",
      "Epoch 187/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 0.0000e+00 - sparse_categorical_accuracy: 1.0000 - val_loss: 1.0390e-05 - val_sparse_categorical_accuracy: 1.0000\n",
      "Epoch 188/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 0.0000e+00 - sparse_categorical_accuracy: 1.0000 - val_loss: 9.9524e-06 - val_sparse_categorical_accuracy: 1.0000\n",
      "Epoch 189/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 0.0000e+00 - sparse_categorical_accuracy: 1.0000 - val_loss: 8.9543e-06 - val_sparse_categorical_accuracy: 1.0000\n",
      "Epoch 190/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 0.0000e+00 - sparse_categorical_accuracy: 1.0000 - val_loss: 9.6456e-06 - val_sparse_categorical_accuracy: 1.0000\n",
      "Epoch 191/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 0.0000e+00 - sparse_categorical_accuracy: 1.0000 - val_loss: 8.6177e-06 - val_sparse_categorical_accuracy: 1.0000\n",
      "Epoch 192/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 0.0000e+00 - sparse_categorical_accuracy: 1.0000 - val_loss: 9.0944e-06 - val_sparse_categorical_accuracy: 1.0000\n",
      "Epoch 193/200\n",
      "160/160 [==============================] - 1s 3ms/sample - loss: 0.0000e+00 - sparse_categorical_accuracy: 1.0000 - val_loss: 8.5432e-06 - val_sparse_categorical_accuracy: 1.0000\n",
      "Epoch 194/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 0.0000e+00 - sparse_categorical_accuracy: 1.0000 - val_loss: 8.1022e-06 - val_sparse_categorical_accuracy: 1.0000\n",
      "Epoch 195/200\n",
      "160/160 [==============================] - 1s 3ms/sample - loss: 0.0000e+00 - sparse_categorical_accuracy: 1.0000 - val_loss: 8.2482e-06 - val_sparse_categorical_accuracy: 1.0000\n",
      "Epoch 196/200\n",
      "160/160 [==============================] - 1s 3ms/sample - loss: 0.0000e+00 - sparse_categorical_accuracy: 1.0000 - val_loss: 8.3257e-06 - val_sparse_categorical_accuracy: 1.0000\n",
      "Epoch 197/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 0.0000e+00 - sparse_categorical_accuracy: 1.0000 - val_loss: 8.5491e-06 - val_sparse_categorical_accuracy: 1.0000\n",
      "Epoch 198/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 0.0000e+00 - sparse_categorical_accuracy: 1.0000 - val_loss: 8.7368e-06 - val_sparse_categorical_accuracy: 1.0000\n",
      "Epoch 199/200\n",
      "160/160 [==============================] - 0s 3ms/sample - loss: 0.0000e+00 - sparse_categorical_accuracy: 1.0000 - val_loss: 8.3048e-06 - val_sparse_categorical_accuracy: 1.0000\n",
      "Epoch 200/200\n",
      "160/160 [==============================] - 0s 3ms/sample - loss: 0.0000e+00 - sparse_categorical_accuracy: 1.0000 - val_loss: 8.7368e-06 - val_sparse_categorical_accuracy: 1.0000\n"
     ]
    }
   ],
   "source": [
    "history = model.fit(xTrain, yTrain, batch_size=1, validation_data=(xTest, yTest), epochs=200, verbose=1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "26996"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "converter = tf.lite.TFLiteConverter.from_keras_model(model)\n",
    "tflite_model = converter.convert()\n",
    "\n",
    "open(\"model\", \"wb\").write(tflite_model)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [],
   "source": [
    "!xxd -i model >> model.h"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.7"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
